
*****************************
*** EXPERIMENTAL ANALYSIS ***
*****************************

clear
cd "/Users/samtrachtman/Dropbox/ACA Study/Projects/Public Private Field Experiment/APSR production/replication materials/submission_data/experiment"
set more off 
set mem 100000






*******************
*** APPENDED DATA ***
*******************

use cleaned_ph, replace
append using cleaned_dig

*drop missing obs
	keep if uptake != . & tr_gov != .

*coding pro govt / anti-govt variable 
	gen pro_govt = 1 if govt_waste01 == 1
	replace pro_govt = 0 if govt_waste == 0
	gen pro_reg = 1 if govt_reg == 1
	replace pro_reg = 0 if govt_reg == 2
	egen gov_scaled = rmean(pro_govt pro_reg)
	save dig_ph_append, replace


*code republican variable 
	gen republican = 1 if party3 == 3
	replace republican = 0 if party3 == 1

****************
*** TABLE 1  ***
****************
	reg uptake tr_gov if party3 == 1, robust cluster (zip)
	reg uptake tr_gov if party3 == 2, robust cluster (zip)
	reg uptake tr_gov if party3 == 3, robust cluster (zip)
	
	reg uptake tr_gov if ideology3 == 1, robust cluster (zip)
	reg uptake tr_gov if ideology3 == 2, robust cluster (zip)
	reg uptake tr_gov if ideology3 == 3, robust cluster (zip)
	

*power calculation
	egen std1 = sd(uptake) if party3 == 3 & tr_gov == 0
	egen std2 = sd(uptake) if party3 == 3 & tr_gov == 1
	drop std1 std2
	local std1 = .502
	local std2 = .452
	power twomeans .48 .28, sd1(.502) sd2(.452) n(178)
	power twomeans .48 .28, sd1(.502) sd2(.452) n(178) nratio(.461)

*difference in treatment effects significant?
	preserve
	keep if party3 == 1 | party3 == 3
	gen party = 1 if party3 == 3
	replace party = 0 if party3 == 1
	gen inter = tr_gov*party
	reg uptake tr_gov party inter
	restore

****************
*** TABLE A5 ***
****************
	sum age2 income college gender1 
	
*balance (regressing treatment on covariates)
	reg tr_gov edu race gender1 age income_quartiles party3 pro_govt pro_reg

**************
***Table A6 ***
****************
	use full_joint_data, clear
	cd "/Users/samtrachtman/Dropbox/ACA Study/Projects/Public Private Field Experiment/APSR production/replication materials/submission_output/experiment"
	
*simple analysis of whether insured
	reg insured tr_gov, robust cluster(zip)
	reg insured tr_gov if party3 == 1, robust cluster(zip)
	reg insured tr_gov if party3 == 2, robust cluster(zip)
	reg insured tr_gov if party3 == 3, robust cluster(zip)	
	
	
*restrict to uninsured, marketplace, ESI
	preserve
	keep if enroll == 1 | enroll == 4 | enroll == 5

	gen insured1 = 1 if enroll == 4 | enroll == 5
	replace insured1 = 0 if enroll == 1

	mlogit enroll tr_gov if party3 == 3, rrr base(1)
	margins, dydx(tr_gov) pr(out(1)) post
	matrix output1 = r(table)'
	putexcel set exp_logistic2, sheet("rep", replace) modify
	putexcel A1 = matrix(output1), names 

	mlogit enroll tr_gov if party3 == 3, rrr base(1)
	margins, dydx(tr_gov) pr(out(4)) post
	matrix output2 = r(table)'
	putexcel set exp_logistic2, sheet("rep") modify
	putexcel A3 = matrix(output2), names 

	mlogit enroll tr_gov if party3 == 3, rrr base(1)
	margins, dydx(tr_gov) pr(out(5)) post
	matrix output3= r(table)'
	putexcel set exp_logistic2, sheet("rep") modify
	putexcel A5 = matrix(output3), names 

	mlogit enroll tr_gov if party3 == 2, rrr base(1)
	margins, dydx(tr_gov) pr(out(1)) post
	matrix output1 = r(table)'
	putexcel set exp_logistic2, sheet("ind", replace) modify
	putexcel A1 = matrix(output1), names 

	mlogit enroll tr_gov if party3 == 2, rrr base(1)
	margins, dydx(tr_gov) pr(out(4)) post
	matrix output2 = r(table)'
	putexcel set exp_logistic2, sheet("ind") modify
	putexcel A3 = matrix(output2), names 

	mlogit enroll tr_gov if party3 == 2, rrr base(1)
	margins, dydx(tr_gov) pr(out(5)) post
	matrix output3= r(table)'
	putexcel set exp_logistic2, sheet("ind") modify
	putexcel A5 = matrix(output3), names 

	mlogit enroll tr_gov if party3 == 1, rrr base(1)
	margins, dydx(tr_gov) pr(out(1)) post
	matrix output1 = r(table)'
	putexcel set exp_logistic2, sheet("dem", replace) modify
	putexcel A1 = matrix(output1), names 

	mlogit enroll tr_gov if party3 == 1, rrr base(1)
	margins, dydx(tr_gov) pr(out(4)) post
	matrix output2 = r(table)'
	putexcel set exp_logistic2, sheet("dem") modify
	putexcel A3 = matrix(output2), names 

	mlogit enroll tr_gov if party3 == 1, rrr base(1)
	margins, dydx(tr_gov) pr(out(5)) post
	matrix output3= r(table)'
	putexcel set exp_logistic2, sheet("dem") modify
	putexcel A5 = matrix(output3), names 
	restore

****************
*** TABLE A7 ***
****************

*restrict to uninsured, marketplace, other / off-marketplace 
	preserve
	keep if enroll == 1 | enroll == 4 | enroll == 6

	gen insured1 = 1 if enroll == 4 | enroll == 6
	replace insured1 = 0 if enroll == 1

	mlogit enroll tr_gov if party3 == 3, rrr base(1)
	margins, dydx(tr_gov) pr(out(1)) post
	matrix output1 = r(table)'
	putexcel set exp_logistic1, sheet("rep", replace) modify
	putexcel A1 = matrix(output1), names 

	mlogit enroll tr_gov if party3 == 3, rrr base(1)
	margins, dydx(tr_gov) pr(out(4)) post
	matrix output2 = r(table)'
	putexcel set exp_logistic1, sheet("rep") modify
	putexcel A3 = matrix(output2), names 

	mlogit enroll tr_gov if party3 == 3, rrr base(1)
	margins, dydx(tr_gov) pr(out(6)) post
	matrix output3= r(table)'
	putexcel set exp_logistic1, sheet("rep") modify
	putexcel A5 = matrix(output3), names 

	mlogit enroll tr_gov if party3 == 2, rrr base(1)
	margins, dydx(tr_gov) pr(out(1)) post
	matrix output1 = r(table)'
	putexcel set exp_logistic1, sheet("ind", replace) modify
	putexcel A1 = matrix(output1), names 

	mlogit enroll tr_gov if party3 == 2, rrr base(1)
	margins, dydx(tr_gov) pr(out(4)) post
	matrix output2 = r(table)'
	putexcel set exp_logistic1, sheet("ind") modify
	putexcel A3 = matrix(output2), names 

	mlogit enroll tr_gov if party3 == 2, rrr base(1)
	margins, dydx(tr_gov) pr(out(6)) post
	matrix output3= r(table)'
	putexcel set exp_logistic1, sheet("ind") modify
	putexcel A5 = matrix(output3), names 

	mlogit enroll tr_gov if party3 == 1, rrr base(1)
	margins, dydx(tr_gov) pr(out(1)) post
	matrix output1 = r(table)'
	putexcel set exp_logistic1, sheet("dem", replace) modify
	putexcel A1 = matrix(output1), names 
	
	mlogit enroll tr_gov if party3 == 1, rrr base(1)
	margins, dydx(tr_gov) pr(out(4)) post
	matrix output2 = r(table)'
	putexcel set exp_logistic1, sheet("dem") modify
	putexcel A3 = matrix(output2), names 

	mlogit enroll tr_gov if party3 == 1, rrr base(1)
	margins, dydx(tr_gov) pr(out(6)) post
	matrix output3= r(table)'
	putexcel set exp_logistic1, sheet("dem") modify
	putexcel A5 = matrix(output3), names 
	restore

****************
*** TABLE A8 ***
****************

	***series of difference in means
	*uninsured vs. other
	gen depvar = 1 if enroll == 1
	replace depvar = 0 if enroll == 6
	reg depvar tr_gov , robust cluster(zip)
	outreg2 using uninsured_v_other.xls, dec(2) cti(all) st(coef se) noaster replace  //noparen symbol("")
	reg depvar tr_gov if party3 == 1, robust cluster(zip)
	outreg2 using uninsured_v_other.xls, dec(2) cti(dem) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 2, robust cluster(zip)
	outreg2 using uninsured_v_other.xls, dec(2) cti(ind) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 3, robust cluster(zip)
	outreg2 using uninsured_v_other.xls, dec(2) cti(rep) st(coef se) noaster append  //noparen symbol("")

	*uninsured vs. esi
	drop depvar
	gen depvar = 1 if enroll == 1
	replace depvar = 0 if enroll == 5
	reg depvar tr_gov 
	outreg2 using uninsured_v_esi.xls, dec(2) cti(all) st(coef se) noaster replace  //noparen symbol("")
	reg depvar tr_gov if party3 == 1, robust cluster(zip)
	outreg2 using uninsured_v_esi.xls, dec(2) cti(dem) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 2, robust cluster(zip)
	outreg2 using uninsured_v_esi.xls, dec(2) cti(ind) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 3, robust cluster(zip)
	outreg2 using uninsured_v_esi.xls, dec(2) cti(rep) st(coef se) noaster append  //noparen symbol("")

	*esi vs. marketplace
	drop depvar
	gen depvar = 1 if enroll == 5
	replace depvar = 0 if enroll == 4
	reg depvar tr_gov , robust cluster(zip)
	outreg2 using esi_v_marketplace.xls, dec(2) cti(all) st(coef se) noaster replace  //noparen symbol("")
	reg depvar tr_gov if party3 == 1, robust cluster(zip)
	outreg2 using esi_v_marketplace.xls, dec(2) cti(dem) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 2, robust cluster(zip)
	outreg2 using esi_v_marketplace.xls, dec(2) cti(ind) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 3, robust cluster(zip)
	outreg2 using esi_v_marketplace.xls, dec(2) cti(rep) st(coef se) noaster append  //noparen symbol("")

	*marketplace vs. off-marketplace
	drop depvar
	gen depvar = 1 if enroll == 4
	replace depvar = 0 if enroll == 6
	reg depvar tr_gov , robust cluster(zip)
	outreg2 using marketplace_v_other.xls, dec(2) cti(all) st(coef se) noaster replace  //noparen symbol("")
	reg depvar tr_gov if party3 == 1, robust cluster(zip)
	outreg2 using marketplace_v_other.xls, dec(2) cti(dem) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 2, robust cluster(zip)
	outreg2 using marketplace_v_other.xls, dec(2) cti(ind) st(coef se) noaster append  //noparen symbol("")
	reg depvar tr_gov if party3 == 3, robust cluster(zip)
	outreg2 using marketplace_v_other.xls, dec(2) cti(rep) st(coef se) noaster append  //noparen symbol("")

	
	
*******************************
***MTURK MANIPULATION CHECK ***
*******************************

cd "/Users/samtrachtman/Dropbox/ACA Study/Projects/Public Private Field Experiment/APSR production/replication materials/submission_data/experiment"
	use val_mturk, clear
	
	gen party = 1 if party1=="Democrat"
	replace party = 1 if party2 == "Closer to Democratic"
	replace party = 2 if party1=="Republican"
	replace party = 2 if party2 == "Closer to Republican"

	gen impression = 1 if pos_neg=="Mostly negative"
	replace impression = 2 if pos_neg =="Somewhat negative"
	replace impression =3 if pos_neg == "Neither positive nor negative"
	replace impression = 4 if pos_neg =="Somewhat positive"
	replace impression=5 if pos_neg == "Mostly positive"
	 
	gen quality2 = 1 if quality=="Low quality"
	replace quality2 = 2 if quality=="Low-to-Medium quality"
	replace quality2=3 if quality=="Medium quality"
	replace quality2=4 if quality=="Medium-to-high quality"
	replace quality2=5 if quality=="High quality"

	gen likeyou2 = 1 if likeyou=="Not at all"
	replace likeyou2 = 2 if likeyou =="A little"
	replace likeyou2 =3 if likeyou=="Somewhat"
	replace likeyou2 = 4 if likeyou =="A great deal"

	gen likelypurchase = 1 if likely_to_purchase=="Extremely unlikely"
	replace likelypurchase = 2 if likely_to_purchase =="Somewhat unlikely"
	replace likelypurchase =3 if likely_to_purchase =="Neither likely nor unlikely"
	replace likelypurchase = 4 if likely_to_purchase =="Somewhat likely"
	replace likelypurchase = 5 if likely_to_purchase =="Extremely likely"

	gen recommend = 1 if rec=="Extremely unlikely"
	replace recommend = 2 if rec =="Somewhat unlikely"
	replace recommend =3 if rec =="Neither likely nor unlikely"
	replace recommend = 4 if rec =="Somewhat likely"
	replace recommend = 5 if rec =="Extremely likely"
	
*No difference on overall pos/neg impressions of site
	bysort party: ttest impression, by(treatment) unequal

*Repubs think quality of healthplans are better in sherpa
	bysort party: ttest quality2, by(treatment) unequal

*both dems and reps assigned to sherpa think its more conservative
	bysort party: ttest libcon, by(treatment) unequal

*Repubs think sherpa represents free market more than gov
	bysort party: ttest freegovt, by(treatment) unequal 

*Both parties think Sherpa is more Repub, but not sig
	bysort party: ttest demrep, by(treatment) unequal

*Both parties think Sherpa is more likely funded by private source
	bysort party: ttest privpub, by(treatment) unequal

*Reps think sherpa is for people like them
	bysort party: ttest likeyou2, by(treatment) unequal

*Dems say more likely to purchase HC.gov than Reps; Reps more likely Healthsherpa.com
	bysort party: ttest likelypurchase, by(treatment) unequal
	
*Dems more likely to recommend HC.gov; Reps more likely to recommend Healthsherpa.com
	bysort party: ttest recommend, by(treatment) unequal
	

















